<?php

/**
 * core actions.
 *
 * @package    bluejot
 * @subpackage core
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class coreActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
  }

  //Loads a component client-side
  //Takes in a $mod (module), $act (action), and standard parameters
  public function executeLoad($request){

        $module = $_REQUEST['mod'];
        unset($_REQUEST['mod']);
       
        $action = $_REQUEST['act'];
        unset($_REQUEST['act']);

          $vars = array();
       
        if(count($_POST)){
            $vars = $_POST;   
        }
       
        if(count($_GET)){
            $vars = $_GET;           
        }         
       
        sfConfig::set('sf_web_debug', false);       
        sfLoader::loadHelpers('Partial');
        include_component($module, $action, $vars);       
        return sfView::NONE;       
  } 

  //Loads a component client-side
  //Takes in a $class (classname), $method (method), and standard parameters 
  public function executeAPI($request){
        if(@$_REQUEST['debug'] != 'Y'){
            sfConfig::set('sf_web_debug', false);
      }
       
        if(!isset($_REQUEST['class'] ) || !isset($_REQUEST['method'])){
                echo "Cannot execute without class and method parameters.";
                exit;     
        }
       
        $output = Util::nvl(@$_REQUEST['output'], "JSON");
       
        bjGateway::executeAPI($output, $_REQUEST['class'], $_REQUEST['method'], $_REQUEST);
       
        return sfView::NONE;
  }  
}
